package Utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Dictionary;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import portal.entities.AbstractEntity;
import portal.entities.Config;
import portal.entities.Producto;
import portal.entities.ProductoElectroDomestico;
import portal.entities.ProductoInfantil;
import portal.entities.ProductoModa;
import portal.entities.ProductoMueble;
import portal.vo.ProductoVO;

public class Helpers {
	
	public static String idModulo(){
		return "PORTAL-Grupo10";
	}
	
	public static String getFormattedDate(Date fecha){ 
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:SS");
		
		return sdf.format(fecha);
	}
	
	public static Producto getProductoFromVO(ProductoVO vo){
		Producto p;
		if(vo.getProductoElectroDomesticoVO() != null){
			p = new ProductoElectroDomestico();
			p.setVO(vo);
			
		}
		else if(vo.getProductoInfantilVO() != null){
			p = new ProductoInfantil();
			p.setVO(vo);
				
		}
		else if(vo.getProductoMuebleVO() != null){
			p = new ProductoMueble();
			p.setVO(vo);
				
		}
		else if(vo.getProductoModaVO() != null){
			p = new ProductoModa();
			p.setVO(vo);
				
		}
		else
			return null;
		
		return p;
	}

	
	private static Map<String, String> configuration;
	public static Map<String, String> getConfiguration(){
		return configuration;
	}
	
	public static void setConfiguration(List<Config> configs){		
		configuration = new TreeMap<String, String>();
		Iterator<Config> it = configs.iterator();		
		while (it.hasNext()) {
			Config c = it.next();
			configuration.put(c.getConfigurationKey(), c.getConfigurationValue());			
		}
		
		
	}

	
	
	
}
